package com.dream.controller;

import javax.annotation.Resource; 

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.dream.pojo.NoteTakingWall;
import com.dream.service.able.All_Service_able;

/*
 * 笔记页面请求控制层
 */
@RequestMapping("/note")
@Controller
public class NoteController {
	
	
	/*
	 * 笔记的业务处理对象
	 */
	@Resource(name="Note_Taking_Wall_Serviceimpl")
	public All_Service_able<NoteTakingWall> note_taking_wall_serice;
	
	/*
	 * 保存笔记的请求
	 */
	@RequestMapping("insert")
	public String insertnote(String title,String context){
		note_taking_wall_serice.insert(title, context);
		return "forward:read";
	}
	
	/*
	 * 到编辑笔记页面的请求
	 */
	@RequestMapping("write")
	public String getwritenote(String title,String context){
		return "writenote";
	}
	
	/*
	 * 查看笔记页面的请求
	 */
	@RequestMapping("read")
	public String getreadnote(Model model){
		model.addAttribute("note_taking_wall", note_taking_wall_serice.list());
		return "note_taking_wall";
	}
	
}
